/*
 *@Author: 张楚
 *@Date: 2021-07-28 19:52:24
 *@Description: 依赖注入
*/

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:totaldemo/getx/controller.dart';
import 'package:totaldemo/getx/dependency_put_find_nextpage.dart';

class DependencyPutFindView extends StatelessWidget {
  DependencyPutFindView({Key key}) : super(key: key);

  ///依赖注入
  final controller = Get.put<GetPutController>(GetPutController());
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('依赖注入'),
      ),
      body: Center(
        child: Column(
          children: [
            GetX<GetPutController>(
              init: controller,
              initState: (_) {},
              builder: (_) {
                return Text('value--->${_.count}');
              },
            ),
            Divider(
              height: 10,
            ),
            ElevatedButton(
              onPressed: () {
                controller.add();
              },
              child: Text('点击增加数值'),
            ),
            ElevatedButton(
              onPressed: () {
                Get.to(() => NextPage(),
                    arguments: {'name': 'lucy', 'age': 12});
              },
              child: Text('点击跳转到下一个页面'),
            ),
          ],
        ),
      ),
    );
  }
}
